package org.timeismoney.payment.model;

import java.io.Serializable;
import java.math.BigDecimal;

public class ItemUnitDetail extends ItemPaymentDetail implements Serializable {

	private static final long	serialVersionUID	= 8552937340094373465L;

	private Unit				unit;

	public ItemUnitDetail() {
	}

	public ItemUnitDetail(Unit unit) {
		super();
		this.unit = unit;
	}

	public ItemUnitDetail(Item item, SchoolYear schoolYear, BigDecimal cost,
			Unit unit) {
		super(item, schoolYear, cost);
		this.unit = unit;
	}

	public ItemUnitDetail(Item item, SchoolYear schoolYear, BigDecimal cost,
			String comment, Unit unit) {
		super(item, schoolYear, cost, comment);
		this.unit = unit;
	}

	public Unit getUnit() {
		return this.unit;
	}

	public void setUnit(Unit unit) {
		this.unit = unit;
	}

	@Override
	public String toString() {
		return "ItemUnitDetail [unit=" + unit + ", ItemPaymentDetail="
				+ super.toString() + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj instanceof ItemStuDetail) {
			ItemStuDetail other = (ItemStuDetail) obj;
			Item item = other.getItem();
			return getItem().equals(item);
		}else if (!(obj instanceof ItemUnitDetail))
			return false;
		ItemUnitDetail other = (ItemUnitDetail) obj;
		Item item = other.getItem();
		return getItem().equals(item);
	}
}
